/***************************************************************************
 *   Copyright (C) 2008 by Thomas Richards   *
 *   thomi@colon   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H

#include "plugin.h"
#include <QMap>
/**
	@author Thomas Richards <thomi@colon>
*/
class PluginManager: public QObject
{
	Q_OBJECT
public:
    ~PluginManager();

	static PluginManager &instance();
	
	enum tPluginType
	{
		PLUGIN_TYPE_GETTER,
  		PLUGIN_TYPE_BROWSER,
		PLUGIN_TYPE_SCANNER,
  		PLUGIN_TYPE_OUTPUT
	};
	
	void registerPlugin(const QString &strPluginPath, tPluginType type);
	
	// get a string list of the available plugins of the specified type:
	QStringList getAvailablePlugins(tPluginType type);
	
	// get a plugin by the plugin name and type:
	Plugin *getPluginByName(const QString &strPluginName, tPluginType type) const;
	
private:
	PluginManager();
	
	enum tPluginLanguage
	{
		PLUGIN_LANG_PYTHON,
  		PLUGIN_LANG_UNKNOWN
	};
	
	tPluginLanguage getPluginLanguage(const QString &strPluginPath) const;
	
	// map of plugin languages to command line options:
	QMap<tPluginLanguage, QString> m_mapPluginCommandLines;
	
	// plugins fall into different categories: getters, browsers, and scanners:
	// each mapmaps pluginName -> pluginPath
	QMap<QString,QString> m_mapGetterPlugins;
	QMap<QString,QString> m_mapBrowserPlugins;
	QMap<QString,QString> m_mapScannerPlugins;
	QMap<QString,QString> m_mapOutputPlugins;
	
	// get a plugin class from the path:
	Plugin *getPluginFromPath(const QString &strPath) const;
};

#endif
